import request from '@/utils/request'

// 用户列表
export const getUserList = (params) => {
  return request({
    url: '/CompanyWebsiteApi/SystemManage/User/GetUserList',
    method: 'GET',
    params
  });
}

// 添加用户
export const addUser = (data) => {
  return request({
    url: '/CompanyWebsiteApi/SystemManage/User/AddUser',
    method: 'POST',
    data
  });
}

// 更新用户
export const updateUser = (data) => {
  return request({
    url: '/CompanyWebsiteApi/SystemManage/User/UpdateUser',
    method: 'POST',
    data
  });
}

// 删除用户
export const deleteUser = (data) => {
  return request({
    url: '/CompanyWebsiteApi/SystemManage/User/DeleteUser',
    method: 'POST',
    data
  });
}

// 启用用户
export const enableUser = (data) => {
  return request({
    url: '/CompanyWebsiteApi/SystemManage/User/EnabledUser',
    method: 'POST',
    data
  });
}

// 禁用用户
export const disableUser = (data) => {
  return request({
    url: '/CompanyWebsiteApi/SystemManage/User/DisabledUser',
    method: 'POST',
    data
  });
}


export function login(data) {
  return request({
    url: '/CompanyWebsiteApi/SystemManage/User/Login',
    // url: '/vue-element-admin/user/login',
    method: 'post',
    // data: {
    //   password: data.pwd,
    //   username: data.name
    // }
    headers: { 'content-type': 'application/json-patch+json' },
    data: {
      loginName: data.name,
      loginPassword: data.pwd
    }
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-element-admin/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}
